package eddy.yang.client;

import java.awt.Dimension;
import java.awt.Toolkit;

import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;

public class Main extends ChinaChessClientFrame {
	private static final long serialVersionUID = 7375866694493663117L;

	public static void main(String[] args) {
		ChinaChessClientFrame cf = new ChinaChessClientFrame();

		String ip = JOptionPane.showInputDialog(cf, "Input server IP:");
		if(ip == null || ip.trim().equals("")) {
			System.exit(0);
		}
		
		Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
		cf.setLocation(d.width / 2 - cf.getWidth() / 2, d.height / 2 - cf.getHeight() / 2);
		cf.setVisible(true);

		try {
			UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
			SwingUtilities.updateComponentTreeUI(cf);
		} catch (Exception ex) {
			ex.printStackTrace();
		}

		ip = "127.0.0.1";
		ListenRunnable lr = new ListenRunnable(cf, ip);
		Thread listenerThread = new Thread(lr);
		listenerThread.start();
	}
}
